<template>
	<view class="control">
		<QSNavbar :navbarItems="navbarItems_1" backgroundColor="#fff"></QSNavbar>
		<!-- <view class="section-1">
			<view class="info-1">当前定位</view>
			<view class=" flex-between">
				<view class="flex-align info-2">
					<image mode="aspectFit" src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/ea1f2e739bfdf3822cf54698e350187782d32706.png"/>
					<text>上海市</text>
				</view>
				<view class="info-3">当前定位</view>
			</view>
		</view> -->

		<view class="section-2">
			<view class="info-1">热门城市</view>
			<view class="list">
				<view class="item" v-for="(item) in list" :key="item.num">
					<view class="tag" @click="href(item)">{{item.name}}</view>
					<view class="city-list">
						<view class="tag" v-show="items.is_select === 1" v-for="items in item.citys" :key="items.num"
							@click="href(items)">
							{{items.name}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import QSNavbar from '@/components/QS-Navbar/QS-Navbar.vue';
	const index = require('@/api/index/index.js')
	export default {
		components: {
			QSNavbar,
		},
		data() {
			return {
				list: [],
				navbarItems_1: [{
						type: 'icon',
						icon: 'back',
						width: 10,
						doEvent: 'redirectTo',
						targetPath: '/pages/venues/index',
						layout: 'left'
					},
					{
						layout: 'left',
						type: 'text',
						text: '所有场馆',
						width: 30,
						weight: 'bold',
						color: '#000',
					},
				],
			}
		},
		onLoad(options) {
			this.getAdress()
			this.getCity(options)
		},
		methods: {
			getAdress() {
				uni.getLocation({
					type: 'wgs84',
					geocode: true,
					success(res) {
					}
				})
			},
			async getCity(options) {
				let data = await index.getCity({
					venues_id: options.id,
					projectId: getApp().globalData.projectId,
					appId: this.$https.weixinAppId,
				})
				if (data.code == 1) {
					this.list = data.data.data
				}
			},
			href(item) {
				if (item.citys) {
					uni.redirectTo({
						url: `/pages/venues/index?province=${item.num}&name=${item.name}`
					})
				} else {
					uni.redirectTo({
						url: `/pages/venues/index?city=${item.num}&name=${item.name}`
					})
				}

			}
		}
	}
</script>

<style scoped lang="scss">
	.control {
		width: 100%;
		min-height: 100vh;
		background-color: #f3f3f3;

		.section-1 {
			padding: 30rpx;
			box-sizing: border-box;
			background-color: white;

			.info-1 {
				font-size: 24rpx;
				color: #acacac;
				margin-bottom: 30rpx;
			}

			.info-2 {
				font-size: 28rpx;
				color: black;
				font-weight: 700;

				text {
					margin-left: 10rpx;
				}

				image {
					width: 30rpx;
					height: 30rpx;
				}
			}

			.info-3 {
				color: #8ac5ea;
				font-size: 24rpx;
			}
		}

		.section-2 {
			padding: 30rpx;
			box-sizing: border-box;
			background-color: white;
			margin-top: 30rpx;

			.info-1 {
				font-size: 24rpx;
				color: #acacac;
				margin-bottom: 30rpx;
			}

			.list {
				.item {
					margin-top: 30rpx;

					.tag {
						border-radius: 10rpx;
						color: black;
						font-size: 22rpx;
						width: fit-content;
						border: 1px solid #e7e7e7;
						padding: 19rpx 10rpx;
						width: fit-content;
						height: 70rpx;
						text-align: center;
						font-weight: 700;
						font-size: 25rpx;
					}

					.city-list {
						margin-top: 30rpx;
						display: flex;
						flex-wrap: wrap;
						padding-left: 40rpx;

						.tag {
							margin-right: 30rpx;
							margin-bottom: 20rpx;
							font-weight: 400;
						}
					}
				}
			}
		}
	}
</style>
